<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        input {
            width: 300px;
        }

        .book span {
            display: inline-block;
            width: 100px;
            text-align: center;
            border-right: 1px solid black;
            border-bottom: 1px solid black;
            box-sizing: border-box;
        }
    </style>
</head>

<body>
    <div class="root">
        <sou></sou>
        <show></show>
    </div>
    <template id="sou">
        <div>
            <input type="text" placeholder="请输入图书名称">

        </div>
    </template>
    <template id="show">
        <div class="book">
            <div>
                <span>id</span><span>书名</span><span>添加时间</span><span>操作</span>
            </div>
            <div v-for="(item, index) in arr" :key="index">
                <div>
                    <span>{{item.id}}</span><span>{{item.book}}</span><span>{{item.time}}</span><span><a>详情</a><button>删除</button></span>
                </div>

            </div>



    </template>
    <script src="./moment.min.js"></script>
    <script src="./vue.js"></script>
    <script>
        //阻止vue在启动时生成生产提示
        Vue.config.productionTip = false;
        const bus = new Vue();
        const sou = {
            template: '#sou',
        }
        const show = {
            template: '#show',
            data() {
                return {
                    arr: [
                        { id: 1, book: '三国演义', time: moment(Date.now()).format('YYYY-MM-DD'), },
                        { id: 2, book: '红楼梦', time: moment(Date.now()).format('YYYY-MM-DD'), },
                        { id: 3, book: '水浒传', time: moment(Date.now()).format('YYYY-MM-DD'), },
                        { id: 4, book: '西游记', time: moment(Date.now()).format('YYYY-MM-DD'), },

                    ]
                }
            }
        }
        //创建vue实例
        new Vue({
            el: '.root',
            data: function () {
                return {
                    // arr:[
                    //     {id:1,book:'三国演义',time: moment(Date.now()).format('YYYY-MM-DD') ,}
                    // ]
                }
            },
            components: {
                sou, show,
            }
        })
    </script>
</body>

</html>